//
//  BaseTableAdapter.m
//  adapter
//
//  Created by ac-hu on 2018/7/1.
//  Copyright © 2018年 ac-hu. All rights reserved.
//

#import "BaseTableAdapter.h"

@interface BaseTableAdapter()



@end

@implementation BaseTableAdapter
-(instancetype)initWith:(UITableView *)table{
    self = [super init];
    if (self) {
        self.table = table;
        self.table.delegate = self;
        self.table.dataSource = self;
        self.table.tableFooterView = [UIView new];
        self.dataArr = [NSMutableArray arrayWithCapacity:0];
    }
    return self;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _isSection ? [_dataArr[section] count] : _dataArr.count;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return _isSection ? _dataArr.count : 1;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return _height == 0 ? 44 : _height;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    return nil;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    if (self.selectIndexPath) {
        self.selectIndexPath(indexPath);
    }
}

-(void)reloadData{
    
}
@end
